Fix: Bitbucket authentication related repo cloning issue#622
Fix: Bitbucket authentication related repo cloning issue#622aft wants to merge 3 commits intosourcebot-dev:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
To sanity check, will this break Bitbucket server? |
| const username = config.user ?? 'x-token-auth'; | ||
| // Extract username from email if present (e.g., user@example.com -> user) | ||
| // Bitbucket API auth uses the full email, but git clone needs just the username | ||
| const username = config.user |
There was a problem hiding this comment.
To my other comment, I'm not sure if this will break bitbucket server. Might be best to only do this if config.deploymentType is cloud
There was a problem hiding this comment.
Sorry, but I can’t confirm whether it breaks Bitbucket Server or not. I only have access to Cloud.
If no one can verify it, making it conditional might be better.
|
I got this to work on bitbucket cloud, thanks |
Problem
Bitbucket Cloud repository cloning was failing with authentication errors. The root cause was a mismatch between the credential formats required by different Bitbucket operations:
user@example.com)Previously, the code was passing the full email address to git clone URLs, causing authentication failures like:
fatal: Authentication failed for 'https://bitbucket.org/workspace/repo.git'Solution
Extract the username from the configured email address when building git clone URLs for Bitbucket repositories. The fix uses JavaScript's
split('@')[0]to extract the username portion while maintaining the full email for API authentication.The
getAuthCredentialsForRepofunction in utils.ts was updated to handle Bitbucket's specific authentication requirements:cloneUrlWithTokencreateGitCloneUrlWithTokenwhich builds the authenticated URL format:https://username:token@bitbucket.org/...Testing
Related Issues
Fixes #573 - Sourcebot not indexing branches for bitbucket
Note
Fixes Bitbucket clone authentication by aligning credential formats.
getAuthCredentialsForRepoto deriveusernamefromconfig.user.split('@')[0]for Bitbucket when constructingcloneUrlWithTokenWritten by Cursor Bugbot for commit dd8492a. This will update automatically on new commits. Configure here.